<template>
  <div>
    <h2>房型显示</h2>
    <table border="1">
  <tr>  
    <th>昵称</th>
    <th>价格</th>
    <td>可住人数</td>
    <th>面积</th>
    <th>地址</th> 
    <th>入住时间</th>  
    <th>操作</th>
  </tr>
  <tr v-for="item in list">
  
    <td>{{ item.name }}</td>
    <td>{{ item.price }}</td>
    <td>{{ item.num }}</td>
    <td>{{ item.size }}</td>
    <td>{{ item.address }}</td>
    <td>{{ item.sdate }}</td>
   
    <td>
      <input type="button" @click="dele(item.id)" value="删除">
    
    </td>
  </tr>
</table>
  </div>
  共有5条
  每页显示2 条
  当前为第1/3页
  <input type="button" value="首页">

  <input type="button" value="上一页">
  <input type="button" value="下一页">
  <input type="button" value="尾页">
</template>

<script setup lang="ts">
import axios from 'axios';
import { reactive,toRefs,onMounted } from 'vue';
import { useRoute,useRouter } from 'vue-router';
let route=useRoute();
let router=useRouter();
let data:any=reactive({
  state:{

  },
  list:[]
})
let{state,list}=toRefs(data)
onMounted(()=>{
  show()
})
function show()
{
  axios({
  url:'/api/Room/GetType',
  method:'get'
 })
 .then(res=>{
  list.value=res.data.data
 })
 .catch(err=>{

 })
}
const dele=(id:any)=>{
 if(confirm("确定要删除吗?"))
 {
   let obj={
    id:id
   }
   axios({
    url:'/api/Room/dele',
    method:'get',
    params:obj
   })
   .then(res=>{
    if(res.data.data==1)
   {
    alert("删除成功")
   }
   })
   .catch(err=>{

   })


 }
}
</script>

<style scoped>

</style>